import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_study/widgets/public/themes/index.dart';
import 'package:rc_widget/rc_widget.dart';

class AppInputGroup extends StatelessWidget {
  const AppInputGroup(
      {super.key,
      this.prefix,
      this.prepend,
      this.suffix,
      this.append,
      this.onTap,
      this.height,
      this.decoration,
      required this.child});

  final String? prefix;
  final Widget? prepend;
  final String? suffix;
  final Widget? append;
  final Widget child;
  final VoidCallback? onTap;
  final double? height;
  final Decoration? decoration;
  
  @override
  Widget build(Object context) {
    return RcGestureDetector(
      onTap: onTap,
      child: Container(
        width: double.infinity,
        height: height ?? 88.h,
        padding: AppSpacings.h24,
        decoration: decoration ?? BoxDecoration(
          border: Border.all(color: AppThemes.of().colors.border1),
          borderRadius: BorderRadius.circular(16.sp), 
        ),
        child: Row(children: [
          _buildPrepend(),
          _buildContent(),
            _buildAppend(),
        ],),
        ),
    );
  }
  
  Widget _buildPrepend() {
    return prepend ?? (prefix != null ? Text( prefix!,style: AppThemes.of().w400Text128,): const SizedBox.shrink());
  }
  
  Widget _buildContent() {
    return Expanded(child: child);
  }
  
  Widget _buildAppend() {
    return append ?? (suffix != null ? Container(
      padding: EdgeInsets.only(left: 16.w),
      child:Text(
        suffix!,
        style: AppThemes.of().w400Text128,
      )
    ):const SizedBox.shrink());
  }
}
